home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_11_02 / 1102084a < prev    next >
Text File  |  1992-12-12  |  7KB  |  217 lines

  1.         case 16: /* image thresholding */
  2.            printf("\nCIPS> Enter input image name\n");
  3.            get_image_name(name);
  4.            printf("\nCIPS> Enter output image name\n");
  5.            get_image_name(name2);
  6.            get_parameters(&il, &ie, &ll, &le);
  7.            get_threshold_options(ts_method, &hi, 
  8.                                  &low, &value);
  9.            if(ts_method[0] == 'm' ||
  10.               ts_method[0] == 'M')
  11.               manual_threshold_segmentation(name,
  12.                      name2, the_image, out_image,
  13.                      il, ie, ll, le, 
  14.                      hi, low, value, 0);
  15.            if(ts_method[0] == 'p' ||
  16.               ts_method[0] == 'P')
  17.               peak_threshold_segmentation(name,
  18.                      name2, the_image, out_image,
  19.                      il, ie, ll, le, value, 0);
  20.            if(ts_method[0] == 'v' ||
  21.               ts_method[0] == 'V')
  22.               valley_threshold_segmentation(name,
  23.                      name2, the_image, out_image,
  24.                      il, ie, ll, le, value, 0);
  25.            if(ts_method[0] == 'a' ||
  26.               ts_method[0] == 'a')
  27.               adaptive_threshold_segmentation(name,
  28.                      name2, the_image, out_image,
  29.                      il, ie, ll, le, value, 0);
  30.         break;
  31.  
  32.         case 17: /* image segmentation */
  33.            printf("\nCIPS> Enter input image name\n");
  34.            get_image_name(name);
  35.            printf("\nCIPS> Enter output image name\n");
  36.            get_image_name(name2);
  37.            get_parameters(&il, &ie, &ll, &le);
  38.            get_segmentation_options(ts_method, &hi, 
  39.                                     &low, &value);
  40.            if(ts_method[0] == 'm' ||
  41.               ts_method[0] == 'M')
  42.               manual_threshold_segmentation(name,
  43.                      name2, the_image, out_image,
  44.                      il, ie, ll, le, 
  45.                      hi, low, value, 1);
  46.            if(ts_method[0] == 'p' ||
  47.               ts_method[0] == 'P')
  48.               peak_threshold_segmentation(name,
  49.                      name2, the_image, out_image,
  50.                      il, ie, ll, le, value, 1);
  51.            if(ts_method[0] == 'v' ||
  52.               ts_method[0] == 'V')
  53.               valley_threshold_segmentation(name,
  54.                      name2, the_image, out_image,
  55.                      il, ie, ll, le, value, 1);
  56.            if(ts_method[0] == 'a' ||
  57.               ts_method[0] == 'a')
  58.               adaptive_threshold_segmentation(name,
  59.                      name2, the_image, out_image,
  60.                      il, ie, ll, le, value, 1);
  61.         break;
  62.  
  63.                            .
  64.                            .
  65.                            .
  66.  
  67.    /******************************************************
  68.    *
  69.    *   show_menu(..
  70.    *
  71.    *   This function displays the CIPS main menu.
  72.    *
  73.    *******************************************************/
  74. show_menu()
  75. {
  76.  
  77.         printf("\n\nWelcome to CIPS");
  78.         printf("\nThe C Image Processing System");
  79.         printf("\nThese are you choices:");
  80.         printf("\n\t1.  Display image header");
  81.         printf("\n\t2.  Show image numbers");
  82.         printf("\n\t3.  Print image numbers");
  83.         printf("\n\t4.  Display image (VGA & EGA only)");
  84.         printf("\n\t5.  Display or print image using halftoning");
  85.         printf("\n\t6.  Print graphics image using dithering");
  86.         printf("\n\t7.  Print or display histogram numbers");
  87.         printf("\n\t8.  Perform edge detection");
  88.         printf("\n\t9.  Perform edge enhancement");
  89.         printf("\n\t10. Perform image filtering");
  90.         printf("\n\t11. Perform image addition and subtraction");
  91.         printf("\n\t12. Perform image cutting and pasting");
  92.         printf("\n\t13. Perform image rotation and flipping");
  93.         printf("\n\t14. Perform image scaling");
  94.         printf("\n\t15. Create a blank image");
  95.         printf("\n\t16. Perform image thresholding");
  96.         printf("\n\t17. Perform image segmentation");
  97.         printf("\n\t20. Exit system");
  98.         printf("\n\nEnter choice _\b");
  99.  
  100. }    /* ends show_menu */
  101.  
  102.                            .
  103.                            .
  104.                            .
  105.  
  106.    /********************************************
  107.    *
  108.    *   get_segmentation_options(...
  109.    *
  110.    *   This function interacts with the user 
  111.    *   to obtain the options for image 
  112.    *   segmentation.
  113.    *
  114.    *********************************************/
  115.  
  116. get_segmentation_options(method, hi, low, value)
  117.    char   method[];
  118.    short  *hi, *low, *value;
  119. {
  120.    int   i, not_finished = 1, response;
  121.  
  122.    while(not_finished){
  123.       printf("\n\nThe image segmentation options are:\n");
  124.       printf("\n\t1. Method is %s", method);
  125.       printf("\n\t   (options are manual peaks");
  126.       printf(        " valleys adapative)");
  127.       printf("\n\t2. Value is %d", *value);
  128.       printf("\n\t3. Hi    is %d", *hi);
  129.       printf("\n\t4. Low   is %d", *low);
  130.       printf("\n\t   Hi and Low needed only for");
  131.       printf(        " manual method");
  132.       printf("\n\nEnter choice (0 = no change):_\b");
  133.  
  134.       get_integer(&response);
  135.  
  136.       if(response == 0)
  137.          not_finished = 0;
  138.  
  139.       if(response == 1){
  140.          printf("\nEnter method (options are:");
  141.          printf(" manual peaks valleys adaptive)\n\t");
  142.          read_string(method);
  143.       }
  144.  
  145.       if(response == 2){
  146.          printf("\nEnter value: ___\b\b\b");
  147.          get_short(value);
  148.       }
  149.  
  150.       if(response == 3){
  151.          printf("\nEnter hi: ___\b\b\b");
  152.          get_short(hi);
  153.       }
  154.       if(response == 4){
  155.          printf("\nEnter low: ___\b\b\b");
  156.          get_short(low);
  157.       }
  158.  
  159.    }  /* ends while not_finished */
  160. }  /* ends get_segmentation_options */
  161.  
  162.    /********************************************
  163.    *
  164.    *   get_threshold_options(...
  165.    *
  166.    *   This function interacts with the user 
  167.    *   to obtain the options for image 
  168.    *   threshold.
  169.    *
  170.    *********************************************/
  171.  
  172. get_threshold_options(method, hi, low, value)
  173.    char   method[];
  174.    short  *hi, *low, *value;
  175. {
  176.    int   i, not_finished = 1, response;
  177.    while(not_finished){
  178.       printf("\n\nThe image threshold options are:\n");
  179.       printf("\n\t1. Method is %s", method);
  180.       printf("\n\t   (options are manual peaks");
  181.       printf(        " valleys adapative)");
  182.       printf("\n\t2. Value is %d", *value);
  183.       printf("\n\t3. Hi    is %d", *hi);
  184.       printf("\n\t4. Low   is %d", *low);
  185.       printf("\n\t   Hi and Low needed only for");
  186.       printf(        " manual method");
  187.       printf("\n\nEnter choice (0 = no change):_\b");
  188.  
  189.       get_integer(&response);
  190.  
  191.       if(response == 0)
  192.          not_finished = 0;
  193.  
  194.       if(response == 1){
  195.          printf("\nEnter method (options are:");
  196.          printf(" manual peaks valleys adaptive)\n\t");
  197.          read_string(method);
  198.       }
  199.  
  200.       if(response == 2){
  201.          printf("\nEnter value: ___\b\b\b");
  202.          get_short(value);
  203.       }
  204.  
  205.       if(response == 3){
  206.          printf("\nEnter hi: ___\b\b\b");
  207.          get_short(hi);
  208.       }
  209.       if(response == 4){
  210.          printf("\nEnter low: ___\b\b\b");
  211.          get_short(low);
  212.       }
  213.  
  214.    }  /* ends while not_finished */
  215. }  /* ends get_threshold_options */
  216.  
  217.